<?php

namespace App\Admin\Actions\ShopOrder;

use App\Library\Logic\OperateLogLogic;
use App\Models\ShopOrderModel;
use Encore\Admin\Actions\Response;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;

class ShopOrderSellerRemarkAction extends RowAction
{
    public $name = '卖家备注';

    public function handle(ShopOrderModel $model, Request $request): Response
    {
        $model->ext->seller_remark = $request->remark;
        $model->ext->save();
        OperateLogLogic::add(Admin::user()->user_id, 'admin.shopOrder.sellerRemark');
        return $this->response()->success('操作成功！');
    }

    public function form(ShopOrderModel $model): void
    {
        $this->textarea('remark', __('shop_order.sellerRemark'))->default($model->ext->seller_remark)->required();
    }
}
